package com.qf.controller;

import com.qf.dto.ScheduleDto;
import com.qf.entity.Comment;
import com.qf.service.StudentService;
import com.qf.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/student/")
public class StudentController {

    @Autowired
    private StudentService studentService;

    //课程表 p
    @RequestMapping("select.do")
    @ResponseBody
    public R SelectList(HttpSession session){

        String snumber = String.valueOf( session.getAttribute("userId"));

       return studentService.SelectList(snumber);

    }

    //评教 p
    @RequestMapping("comment.do")
    @ResponseBody
    public R Comment(Comment comment,HttpSession session){
        String snumber = String.valueOf(session.getAttribute("userId"));
        comment.setSnumber(snumber);
        return studentService.Comment(comment);
    }
    //查看成绩 p
    @RequestMapping("score.do")
    @ResponseBody
    public R selectScore(HttpSession session){
        String snumber = String.valueOf(session.getAttribute("userId"));
        return studentService.selectScore(snumber);
    }
    //选课 p
    @RequestMapping("courseSelectInsert.do")
    @ResponseBody
    public R coureSelect(HttpSession session, int courseId){
        String snumber = String.valueOf( session.getAttribute("userId"));
        return studentService.courseSelectInsert(snumber,courseId);
    }
    //展示可选课程 p
    @RequestMapping("courseSelectAll.do")
    @ResponseBody
    public R courseSelectAll(){
        return studentService.courseSelectAll();
    }

    @GetMapping("selectStudentInfo.do")
    @ResponseBody
    public R selectStudentInfo(int id) {
        return studentService.selectStudentInfo(id);
    }
//    学生查看个人考试安排 J
    @RequestMapping("selectExam.do")
    @ResponseBody
    public R selectExam(HttpSession session) {
        String snumber = (String) session.getAttribute("userId");
        return studentService.selectExam(snumber);
    }
    //    学生对应课程签到 J
    @RequestMapping("signIn.do")
    @ResponseBody
    public R singnIn(int coursecount, HttpSession session, int courseId) {
        String snumber = (String) session.getAttribute("userId");
        return studentService.signIn(coursecount, snumber, courseId);
    }
    //查看补考安排
    @RequestMapping("selectExamtoo.do")
    @ResponseBody
    public R selectExamtoo(HttpSession session){
        String snumber = String.valueOf(session.getAttribute("userId"));
        return studentService.selectExamtoo(snumber);
    }
}
